//
//  WPThirdViewOfBtnView.m
//  wobingwoyi
//
//  Created by WGP on 16/7/26.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPThirdViewOfBtnView.h"

@interface WPThirdViewOfBtnView ()

@property(nonatomic,copy)void(^clickBlock)(WPDiseaseTypes diseaseType);
@property(nonatomic,assign)WPDiseaseTypes diseaseType;

@end

@implementation WPThirdViewOfBtnView

-(instancetype)initWith:(NSString *)imageName title:(NSString *)title introduceStr:(NSString *)introduceStr type:(WPDiseaseTypes)diseaseType block:(void(^)(WPDiseaseTypes diseaseType))clickBlock
{
    if (self = [super init]) {
        
        self.backgroundColor = [UIColor whiteColor];
        
        self.clickBlock = clickBlock;
        self.diseaseType = diseaseType;
        
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
        [self addSubview:imageView];
        
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = title;
        titleLabel.textColor = GLobalFontColor;
        titleLabel.font = [UIFont systemFontOfSize:15];
        [titleLabel sizeToFit];
        [self addSubview:titleLabel];
        
        UILabel *introduceLabel = [UILabel new];
        introduceLabel.text = introduceStr;
        introduceLabel.textColor = GloballightFontColor;
        introduceLabel.font = [UIFont systemFontOfSize:12];
        [introduceLabel sizeToFit];
        [self addSubview:introduceLabel];
        
        UIButton *coverBtn = [[UIButton alloc] init];
        [coverBtn addTarget:self action:@selector(coverBtnDidClick) forControlEvents:UIControlEventTouchDown];
        [self addSubview:coverBtn];
        
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.width.height.mas_equalTo(40*SCALE);
            make.top.equalTo(self).offset(8*SCALE);
        }];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(imageView.mas_bottom).offset(8*SCALE);
        }];
        
        [introduceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(titleLabel.mas_bottom).offset(10*SCALE);
        }];
        
        [coverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
    }
    return self;
}

-(void)coverBtnDidClick
{
    if (self.diseaseType) {
        self.clickBlock(self.diseaseType);
    }
}


@end






